//
//  WQAccount.m
//  sanwuWeiboOC
//
//  Created by 王先强 on 15/12/11.
//  Copyright © 2015年 王先强. All rights reserved.
//

#import "WQAccount.h"

@implementation WQAccount

+(instancetype)accountWithDict:(NSDictionary *)dict{
    WQAccount *account = [[self alloc] init];
    [account setValuesForKeysWithDictionary:dict];
    return account;
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{}

-(void)encodeWithCoder:(NSCoder *)enCoder{
    [enCoder encodeObject:self.access_token forKey:@"access_token"];
    [enCoder encodeObject:self.expires_in forKey:@"expires_in"];
    [enCoder encodeObject:self.uid forKey:@"uid"];
//    [enCoder encodeObject:self.access_token forKey:@"access_token"];
    
}

- (instancetype)initWithCoder:(NSCoder *)deCoder{
    if (self = [super init]) {
        self.access_token = [deCoder decodeObjectForKey:@"access_token"];
        self.expires_in = [deCoder decodeObjectForKey:@"expires_in"];
        self.uid = [deCoder decodeObjectForKey:@"uid"];
    }
    return self;
}

-(void)setExpires_in:(NSString *)expires_in{
    _expires_in = expires_in;
    
    NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:[expires_in doubleValue]];
    NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
    self.expiresDate = [fmt stringFromDate:date];
    
}


@end
